#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：auto-meter-api-python 
@File    ：models_all.py
@IDE     ：PyCharm 
@Author  ：Win_yq.W
@Date    ：2023/4/14 21:48
@DOC     :
"""
from sqlalchemy import BigInteger, Column, Date, DateTime, Float, ForeignKey, Integer, String, Table, Text, text, \
    create_engine
from sqlalchemy.dialects.mysql import BIGINT, TEXT, VARCHAR
from sqlalchemy.orm import relationship, sessionmaker
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()
metadata = Base.metadata

SQLALCHEMY_DATABASE_URL = "mysql+pymysql://username:password@host:port/database_name"

engine = create_engine(
    SQLALCHEMY_DATABASE_URL,
    echo=True
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
session = SessionLocal()


class Account(Base):
    __tablename__ = 'account'
    __table_args__ = {'comment': '用户表'}

    id = Column(BIGINT, primary_key=True, comment='用户Id')
    email = Column(VARCHAR(64), unique=True, comment='邮箱')
    name = Column(VARCHAR(128), nullable=False, unique=True, comment='用户名')
    password = Column(VARCHAR(512), comment='密码')
    register_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='注册时间')
    login_time = Column(DateTime, comment='上一次登录时间')

    roles = relationship('Role', secondary='account_role')


class Api(Base):
    __tablename__ = 'api'
    __table_args__ = {'comment': '微服务表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    deployunitid = Column(BIGINT, nullable=False, comment='DeployUnitId')
    deployunitname = Column(VARCHAR(64), comment='微服务名')
    apiname = Column(VARCHAR(64), comment='接口名')
    visittype = Column(VARCHAR(10), comment='访问方式，字典表获取')
    apistyle = Column(VARCHAR(10), comment='restful,普通方式')
    path = Column(VARCHAR(200), comment='url访问路径')
    requestcontenttype = Column(VARCHAR(64), comment='请求数据格式，form表单，json')
    responecontenttype = Column(VARCHAR(64), comment='响应数据格式，form表单，json')
    memo = Column(VARCHAR(200), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(String(20), comment='创建者')
    requesttype = Column(String(20), server_default=text("'Body传值'"), comment='请求传值方式')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class ApiCasedatum(Base):
    __tablename__ = 'api_casedata'
    __table_args__ = {'comment': 'api用例数据表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    caseid = Column(BIGINT, nullable=False, comment='用例Id')
    casename = Column(VARCHAR(64), comment='用例名')
    apiparam = Column(VARCHAR(200), comment='api参数')
    apiparamvalue = Column(TEXT, comment='用例参数值')
    propertytype = Column(VARCHAR(64), comment='api属性类型，header，body')
    memo = Column(VARCHAR(200), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    paramstype = Column(String(20), comment='参数类型')


class ApiParam(Base):
    __tablename__ = 'api_params'
    __table_args__ = {'comment': 'api参数表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    apiid = Column(BIGINT, nullable=False, comment='apiId')
    apiname = Column(VARCHAR(64), comment='api名')
    deployunitid = Column(BIGINT, nullable=False, comment='微服务Id')
    deployunitname = Column(VARCHAR(64), comment='微服务名')
    propertytype = Column(VARCHAR(64), comment='api属性类型，header，body')
    keyname = Column(TEXT, comment='key名')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(String(20), comment='创建者')
    keydefaultvalue = Column(Text, comment='Key默认值')
    keytype = Column(String(20), comment='参数类型')


class Apicase(Base):
    __tablename__ = 'apicases'
    __table_args__ = {'comment': 'api用例表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    apiid = Column(BIGINT, nullable=False, comment='apiid')
    apiname = Column(VARCHAR(64), comment='API')
    deployunitid = Column(BIGINT, nullable=False, comment='微服务id')
    deployunitname = Column(VARCHAR(64), comment='微服务')
    casename = Column(VARCHAR(64), comment='用例名')
    casejmxname = Column(VARCHAR(64), comment='用例jmx名，和jmx文件名对齐')
    casetype = Column(VARCHAR(10), comment='类型，功能，性能')
    threadnum = Column(BIGINT, nullable=False, comment='线程数')
    loops = Column(BIGINT, nullable=False, comment='循环数')
    casecontent = Column(VARCHAR(64),
                         comment='用例内容，以英文逗号分开，提供jar获取自定义期望结果A：1的值，入参为冒号左边的内容')
    expect = Column(VARCHAR(500), comment='期望值')
    middleparam = Column(VARCHAR(200), comment='中间变量')
    memo = Column(VARCHAR(200), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')
    level = Column(BIGINT, nullable=False, comment='优先级')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class ApicasesAssert(Base):
    __tablename__ = 'apicases_assert'
    __table_args__ = {'comment': '断言表'}

    id = Column(BIGINT, primary_key=True, comment='断言Id')
    caseid = Column(BIGINT, nullable=False, comment='用例id')
    asserttype = Column(VARCHAR(20), comment='断言类型')
    assertsubtype = Column(VARCHAR(20), comment='断言子类型')
    assertvalues = Column(VARCHAR(2000), comment='断言值')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')
    expression = Column(String(20), comment='断言表达式')
    assertcondition = Column(String(20), comment='断言条件')
    assertvaluetype = Column(String(20), comment='断言值类型')


class ApicasesCondition(Base):
    __tablename__ = 'apicases_condition'
    __table_args__ = {'comment': 'api用例条件表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    execplanid = Column(BIGINT, comment='执行计划Id')
    execplanname = Column(VARCHAR(64), comment='执行计划名')
    target = Column(VARCHAR(64), comment='条件目标')
    caseid = Column(BIGINT, comment='用例id')
    envassemid = Column(BIGINT, comment='环境组件id')
    casedeployunitname = Column(VARCHAR(64), comment='用例所属微服务')
    caseapiname = Column(VARCHAR(64), comment='用例所属api')
    casename = Column(VARCHAR(64), comment='用例名')
    basetype = Column(VARCHAR(64), comment='前置，后置')
    conditionbasetype = Column(VARCHAR(64), comment='数据库，接口')
    conditiontype = Column(VARCHAR(64), comment='数据库：mysql，oracle，sqlserver，接口：controller,https,dubbo')
    deployunitname = Column(VARCHAR(64), comment='包含调用接口的微服务')
    apiname = Column(VARCHAR(64), comment='调用接口的api')
    conditionvalue = Column(VARCHAR(500), comment='条件值，如果是数据库为sql，如果是接口为用例名')
    conditioncaseid = Column(BIGINT, comment='条件值id，如果是数据库为空，如果是接口为用例id')
    connectstr = Column(VARCHAR(64), comment='连接字')
    memo = Column(VARCHAR(200), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')


class ApicasesConditionReport(Base):
    __tablename__ = 'apicases_condition_report'
    __table_args__ = {'comment': 'api用例前后置条件运行报告表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    caseid = Column(BIGINT, nullable=False, comment='用例id')
    testplanid = Column(BIGINT, nullable=False, comment='执行计划id')
    batchid = Column(BIGINT, nullable=False, comment='批次id')
    batchname = Column(VARCHAR(64), comment='批次')
    slaverid = Column(BIGINT, nullable=False, comment='执行机id')
    conditiontype = Column(VARCHAR(64), comment='前置，后置')
    casetype = Column(VARCHAR(64), comment='功能，性能')
    status = Column(VARCHAR(64), comment='运行结果，成功，失败，异常')
    errorinfo = Column(VARCHAR(500), comment='错误信息')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')


class ApicasesDebugCondition(Base):
    __tablename__ = 'apicases_debug_condition'
    __table_args__ = {'comment': '用例调试全局条件表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    deployunitid = Column(BIGINT, comment='微服务Id')
    deployunitname = Column(VARCHAR(64), comment='微服务')
    caseid = Column(BIGINT, comment='用例id')
    casename = Column(VARCHAR(64), comment='用例名')
    conditionname = Column(VARCHAR(500), comment='条件名')
    conditionid = Column(BIGINT, comment='条件id')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')


class ApicasesPerformanceapdex(Base):
    __tablename__ = 'apicases_performanceapdex'
    __table_args__ = {'comment': 'api用例性能apdex表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    caseid = Column(BIGINT, nullable=False, comment='用例id')
    testplanid = Column(BIGINT, nullable=False, comment='执行计划id')
    batchname = Column(VARCHAR(64), comment='批次')
    slaverid = Column(BIGINT, nullable=False, comment='执行机id')
    apdex = Column(VARCHAR(64), comment='apdex')
    toleration = Column(VARCHAR(64), comment='toleration')
    frustration = Column(VARCHAR(64), comment='frustration')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')


class ApicasesPerformancestatistic(Base):
    __tablename__ = 'apicases_performancestatistics'
    __table_args__ = {'comment': 'api用例性能统计表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    caseid = Column(BIGINT, nullable=False, comment='用例id')
    testplanid = Column(BIGINT, nullable=False, comment='执行计划id')
    batchname = Column(VARCHAR(64), comment='批次')
    runtime = Column(Float(11, True), nullable=False, comment='运行时长,秒')
    slaverid = Column(BIGINT, nullable=False, comment='执行机id')
    samples = Column(BIGINT, nullable=False, comment='样本')
    errorcount = Column(BIGINT, nullable=False, comment='错误次数')
    errorrate = Column(Float(11, True), nullable=False, comment='错误率')
    average = Column(Float(11, True), nullable=False, comment='平均数')
    min = Column(Float(11, True), nullable=False, comment='最小值')
    max = Column(Float(11, True), nullable=False, comment='最大值')
    median = Column(Float(11, True), nullable=False, comment='中间值')
    nzpct = Column(Float(11, True), nullable=False, comment='90pct')
    nfpct = Column(Float(11, True), nullable=False, comment='95pct')
    nnpct = Column(Float(11, True), nullable=False, comment='99pct')
    tps = Column(Float(11, True), nullable=False, comment='tps')
    receivekbsec = Column(Float(11, True), nullable=False, comment='每秒接受Kb数')
    sendkbsec = Column(Float(11, True), nullable=False, comment='每秒发送Kb数')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class ApicasesReport(Base):
    __tablename__ = 'apicases_report'
    __table_args__ = {'comment': 'api用例报告表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    caseid = Column(BIGINT, nullable=False, comment='用例id')
    testplanid = Column(BIGINT, nullable=False, comment='执行计划id')
    batchname = Column(VARCHAR(64), comment='批次')
    slaverid = Column(BIGINT, nullable=False, comment='执行机id')
    status = Column(VARCHAR(64), comment='运行结果，成功，失败，异常')
    respone = Column(TEXT, comment='返回结果')
    assertvalue = Column(TEXT, comment='断言详细经过')
    runtime = Column(BigInteger, nullable=False, comment='运行时长')
    expect = Column(TEXT, comment='期望值')
    errorinfo = Column(TEXT, comment='错误信息')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')
    requestheader = Column(Text, comment='请求头数据')
    requestdatas = Column(Text, comment='请求数据')
    url = Column(String(200), comment='地址')
    requestmethod = Column(String(20), comment='请求方式')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class ApicasesReportPerformance(Base):
    __tablename__ = 'apicases_report_performance'
    __table_args__ = {'comment': 'api用例报告表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    caseid = Column(BIGINT, nullable=False, comment='用例id')
    testplanid = Column(BIGINT, nullable=False, comment='执行计划id')
    batchname = Column(VARCHAR(64), comment='批次')
    slaverid = Column(BIGINT, nullable=False, comment='执行机id')
    status = Column(VARCHAR(64), comment='运行结果，成功，失败，异常')
    respone = Column(TEXT, comment='返回结果')
    assertvalue = Column(TEXT, comment='断言详细经过')
    runtime = Column(BigInteger, nullable=False, comment='运行时长')
    expect = Column(TEXT, comment='期望值')
    errorinfo = Column(TEXT, comment='错误信息')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')
    requestheader = Column(Text, comment='请求头数据')
    requestdatas = Column(Text, comment='请求数据')
    url = Column(String(200), comment='地址')
    requestmethod = Column(String(20), comment='请求方式')


class ApicasesReportstatic(Base):
    __tablename__ = 'apicases_reportstatics'
    __table_args__ = {'comment': 'api计划批量用例统计报告表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    testplanid = Column(BIGINT, nullable=False, comment='执行计划id')
    deployunitid = Column(BIGINT, nullable=False, comment='发单单元id')
    batchname = Column(VARCHAR(64), comment='批次')
    slaverid = Column(BIGINT, nullable=False, comment='执行机id')
    totalcases = Column(BigInteger, nullable=False, comment='用例总数')
    totalpasscases = Column(BigInteger, nullable=False, comment='用例总数')
    totalfailcases = Column(BigInteger, nullable=False, comment='用例总数')
    runtime = Column(BigInteger, nullable=False, comment='运行时长')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')


class ApicasesVariable(Base):
    __tablename__ = 'apicases_variables'
    __table_args__ = {'comment': 'api用例变量表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    caseid = Column(BIGINT, nullable=False, comment='用例Id')
    casename = Column(VARCHAR(64), comment='用例名')
    variablesid = Column(BIGINT, nullable=False, comment='变量Id')
    variablesname = Column(VARCHAR(64), comment='变量名')
    memo = Column(VARCHAR(200), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(String(20), comment='创建者')
    deployunitname = Column(String(64), comment='微服务')
    apiname = Column(String(64), comment='api')
    apiid = Column(BIGINT, nullable=False, comment='apiid')
    deployunitid = Column(BIGINT, nullable=False, comment='deployunitid')


class ConditionApi(Base):
    __tablename__ = 'condition_api'
    __table_args__ = {'comment': '接口条件表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    conditionid = Column(BIGINT, comment='条件id')
    deployunitid = Column(BIGINT, comment='微服务id')
    caseid = Column(BIGINT, comment='接口caseid')
    memo = Column(VARCHAR(200), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')
    apiid = Column(Integer, nullable=False, comment='apiid')
    conditionname = Column(String(64), comment='条件名')
    deployunitname = Column(String(64), comment='微服务名')
    apiname = Column(String(64), comment='api名')
    casename = Column(String(64), comment='接口名')
    subconditionname = Column(String(64), comment='子条件名')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class ConditionDb(Base):
    __tablename__ = 'condition_db'
    __table_args__ = {'comment': 'db条件表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    conditionid = Column(BIGINT, comment='条件id')
    enviromentid = Column(BIGINT, comment='环境id')
    dbtype = Column(VARCHAR(200), comment='数据库类型')
    dbcontent = Column(Text, comment='db执行内容')
    connectstr = Column(String(200), comment='db连接字')
    memo = Column(VARCHAR(200), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')
    subconditionname = Column(String(64), comment='子条件名')
    assembleid = Column(BIGINT, comment='组件id')
    assemblename = Column(String(64), comment='组件名')
    conditionname = Column(String(64), comment='条件名')
    enviromentname = Column(String(64), comment='环境名')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class ConditionDelay(Base):
    __tablename__ = 'condition_delay'
    __table_args__ = {'comment': '延时子条件表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    conditionid = Column(BIGINT, comment='父条件id')
    conditionname = Column(VARCHAR(64), comment='父条件名')
    subconditionname = Column(VARCHAR(64), comment='子条件名')
    delaytime = Column(BIGINT, comment='延时时间')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class ConditionOrder(Base):
    __tablename__ = 'condition_order'
    __table_args__ = {'comment': '条件顺序表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    conditionid = Column(BIGINT, comment='父条件id')
    subconditionid = Column(BIGINT, comment='子条件id')
    subconditiontype = Column(VARCHAR(20), comment='子条件类型')
    subconditionname = Column(VARCHAR(64), comment='子条件名')
    conditionorder = Column(BIGINT, comment='条件顺序')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')
    conditionname = Column(String(64), comment='父条件名')
    orderstatus = Column(String(20), comment='顺序状态')


class ConditionScript(Base):
    __tablename__ = 'condition_script'
    __table_args__ = {'comment': '脚本条件表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    conditionid = Column(BIGINT, comment='条件id，只取类型为用例')
    script = Column(VARCHAR(4000), comment='脚本')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')
    conditionname = Column(String(64), comment='条件名')
    subconditionname = Column(String(64), comment='子条件名')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class DbconditionVariable(Base):
    __tablename__ = 'dbcondition_variables'
    __table_args__ = {'comment': '数据库条件变量表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    dbconditionid = Column(BIGINT, nullable=False, comment='用例Id')
    dbconditionname = Column(VARCHAR(64), comment='用例名')
    variablesid = Column(BIGINT, nullable=False, comment='变量Id')
    variablesname = Column(VARCHAR(64), comment='变量名')
    fieldname = Column(VARCHAR(64), comment='字段名')
    roworder = Column(BIGINT, nullable=False, comment='行序号')
    memo = Column(VARCHAR(200), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')


class Dbvariable(Base):
    __tablename__ = 'dbvariables'
    __table_args__ = {'comment': '数据库变量表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    dbvariablesname = Column(VARCHAR(64), comment='变量名')
    variablesdes = Column(VARCHAR(64), comment='变量描述')
    valuetype = Column(VARCHAR(64), comment='变量值类型')
    creator = Column(VARCHAR(64), comment='创建人')
    memo = Column(VARCHAR(200), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class Deployunit(Base):
    __tablename__ = 'deployunit'
    __table_args__ = {'comment': '微服务表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    deployunitname = Column(VARCHAR(64), comment='微服务名')
    protocal = Column(VARCHAR(64), nullable=False, comment='协议')
    port = Column(VARCHAR(64), nullable=False, comment='访问端口')
    memo = Column(VARCHAR(512), comment='描述')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(String(20), comment='创建者')
    baseurl = Column(VARCHAR(50), comment='基本路径')
    projectid = Column(BIGINT, comment='项目id')


class Dictionary(Base):
    __tablename__ = 'dictionary'
    __table_args__ = {'comment': '字典表'}

    id = Column(BIGINT, primary_key=True, comment='用户Id')
    dicname = Column(VARCHAR(64), comment='字典类名')
    diccode = Column(VARCHAR(64), nullable=False, comment='字典编码')
    dicitemname = Column(VARCHAR(64), nullable=False, comment='字典项名')
    dicitmevalue = Column(VARCHAR(200), nullable=False, comment='字典项值')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')


class Dispatch(Base):
    __tablename__ = 'dispatch'
    __table_args__ = {'comment': '调度表'}

    id = Column(BIGINT, primary_key=True, comment='环境Id')
    execplanid = Column(BIGINT, nullable=False, comment='执行计划Id')
    execplanname = Column(VARCHAR(64), comment='执行计划名')
    batchid = Column(BIGINT, nullable=False, comment='批次Id')
    batchname = Column(VARCHAR(64), comment='批次名')
    slaverid = Column(BIGINT, nullable=False, comment='执行机Id')
    slavername = Column(VARCHAR(64), comment='执行机名')
    testcaseid = Column(BIGINT, nullable=False, comment='用例Id')
    testcasename = Column(VARCHAR(64), comment='用例名')
    casejmxname = Column(VARCHAR(64), comment='jmeter-class')
    deployunitname = Column(VARCHAR(64), comment='微服务')
    expect = Column(VARCHAR(500), comment='jmeter-class')
    status = Column(VARCHAR(64), comment='待分配，已分配，已结束，调度异常')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    plantype = Column(String(20), comment='计划类型')
    threadnum = Column(BigInteger, comment='线程数')
    loops = Column(BigInteger, comment='循环数')
    memo = Column(String(500), comment='备注')
    creator = Column(VARCHAR(64), comment='创建人')


class Enviroment(Base):
    __tablename__ = 'enviroment'
    __table_args__ = {'comment': '环境表'}

    id = Column(BIGINT, primary_key=True, comment='环境Id')
    enviromentname = Column(VARCHAR(64), comment='环境名')
    envtype = Column(VARCHAR(128), nullable=False, comment='环境类型')
    memo = Column(VARCHAR(128), nullable=False, comment='环境描述')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(String(20), comment='创建者')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class EnviromentAssemble(Base):
    __tablename__ = 'enviroment_assemble'
    __table_args__ = {'comment': '环境组件表'}

    id = Column(BIGINT, primary_key=True, comment='环境Id')
    assemblename = Column(VARCHAR(64), comment='环境组件名')
    assembletype = Column(VARCHAR(64), comment='mysql，oracle，redis')
    connectstr = Column(VARCHAR(64), comment='连接字')
    memo = Column(VARCHAR(128), nullable=False, comment='环境描述')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class Envmachine(Base):
    __tablename__ = 'envmachine'
    __table_args__ = {'comment': '环境服务器表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    envid = Column(BIGINT, nullable=False, comment='环境Id')
    enviromentname = Column(VARCHAR(64), comment='环境名')
    machineid = Column(BIGINT, nullable=False, comment='服务器Id')
    machinename = Column(VARCHAR(64), comment='机器名')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(String(20), comment='创建者')


class Executeplan(Base):
    __tablename__ = 'executeplan'
    __table_args__ = {'comment': '执行计划表'}

    id = Column(BIGINT, primary_key=True, comment='执行计划Id')
    envid = Column(BIGINT, nullable=False, comment='环境Id')
    enviromentname = Column(VARCHAR(64), comment='环境名')
    executeplanname = Column(VARCHAR(64), comment='执行计划名')
    status = Column(VARCHAR(64), nullable=False, comment='状态，new，waiting，running，pause，finish')
    usetype = Column(VARCHAR(512), comment='运行类型，function，performance，来区分分配什么slaver')
    memo = Column(VARCHAR(512), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    businesstype = Column(String(80), comment='业务类型，常规测试，CI自动化测试')
    creator = Column(String(20), comment='创建者')
    runmode = Column(String(20), comment='运行模式，单机运行，多机并发')
    dingdingtoken = Column(VARCHAR(200), nullable=False, comment='通知钉钉token')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class ExecuteplanParam(Base):
    __tablename__ = 'executeplan_params'
    __table_args__ = {'comment': '测试集合全局参数表'}

    id = Column(BIGINT, primary_key=True, comment='主键Id')
    executeplanid = Column(BIGINT, nullable=False, comment='执行计划id')
    paramstype = Column(VARCHAR(64), nullable=False, comment='参数类型')
    keyname = Column(VARCHAR(64), nullable=False, comment='Key')
    keyvalue = Column(Text)
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')


class ExecuteplanTestcase(Base):
    __tablename__ = 'executeplan_testcase'
    __table_args__ = {'comment': '执行计划用例表'}

    id = Column(BIGINT, primary_key=True, comment='主键Id')
    executeplanid = Column(BIGINT, nullable=False, comment='执行计划id')
    apiid = Column(BIGINT, nullable=False, comment='apiid')
    deployunitid = Column(BIGINT, nullable=False, comment='微服务id')
    deployunitname = Column(VARCHAR(64), nullable=False, comment='微服务')
    apiname = Column(VARCHAR(64), nullable=False, comment='API名')
    testcaseid = Column(BIGINT, nullable=False, comment='用例id')
    casename = Column(VARCHAR(64), nullable=False, comment='用例名')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(String(20), comment='操作人')
    caseorder = Column(BIGINT, comment='用例顺序')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class Executeplanbatch(Base):
    __tablename__ = 'executeplanbatch'
    __table_args__ = {'comment': '执行计划表'}

    id = Column(BIGINT, primary_key=True, comment='执行计划Id')
    executeplanid = Column(BIGINT, nullable=False, comment='执行计划id')
    batchname = Column(VARCHAR(64), nullable=False, comment='批次名')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')
    status = Column(String(10), comment='状态，new，waiting，running，pause，finish')
    source = Column(String(10), comment='来源，平台，ci,其他')
    executeplanname = Column(String(100), comment='计划名')
    exectype = Column(String(20), comment='执行类型，立即，某天定时，每天定时')
    execdate = Column(String(20), comment='执行时间')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class Globalheader(Base):
    __tablename__ = 'globalheader'
    __table_args__ = {'comment': '全局Header'}

    id = Column(BIGINT, primary_key=True, comment='主键Id')
    globalheadername = Column(VARCHAR(64), nullable=False, comment='全局header名')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class GlobalheaderParam(Base):
    __tablename__ = 'globalheader_params'
    __table_args__ = {'comment': '全局Header参数'}

    id = Column(BIGINT, primary_key=True, comment='主键Id')
    globalheaderid = Column(BIGINT, nullable=False, comment='globalheaderId')
    keyname = Column(VARCHAR(64), nullable=False, comment='key名')
    keyvalue = Column(Text)
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')


class Globalheaderuse(Base):
    __tablename__ = 'globalheaderuse'
    __table_args__ = {'comment': '集合全局Header'}

    id = Column(BIGINT, primary_key=True, comment='主键Id')
    globalheaderid = Column(BIGINT, nullable=False, comment='globalheaderId')
    executeplanid = Column(BIGINT, nullable=False, comment='集合Id')
    globalheadername = Column(VARCHAR(64), nullable=False, comment='全局header名')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')


class Globalvariable(Base):
    __tablename__ = 'globalvariables'
    __table_args__ = {'comment': '全局变量'}

    id = Column(BIGINT, primary_key=True, comment='主键Id')
    keyname = Column(VARCHAR(64), nullable=False, comment='key名')
    keyvalue = Column(Text)
    memo = Column(VARCHAR(64), nullable=False, comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class Macdepunit(Base):
    __tablename__ = 'macdepunit'
    __table_args__ = {'comment': '服务器微服务表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    depunitid = Column(BIGINT, comment='微服务Id')
    assembleid = Column(BIGINT, comment='组件Id')
    deployunitname = Column(VARCHAR(64), comment='微服务名')
    assembletype = Column(VARCHAR(64), comment='组件类型')
    machineid = Column(BIGINT, nullable=False, comment='服务器Id')
    machinename = Column(VARCHAR(64), comment='机器名')
    envid = Column(BIGINT, nullable=False, comment='环境Id')
    enviromentname = Column(VARCHAR(64), comment='环境名')
    visittype = Column(VARCHAR(10), comment='访问方式，ip,域名')
    domain = Column(VARCHAR(128), nullable=False, comment='服务域名')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(String(20), comment='创建者')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class Machine(Base):
    __tablename__ = 'machine'
    __table_args__ = {'comment': '服务器表'}

    id = Column(BIGINT, primary_key=True, comment='用户Id')
    machinename = Column(VARCHAR(64), comment='机器名')
    ip = Column(VARCHAR(64), nullable=False, comment='ip')
    cpu = Column(VARCHAR(64), nullable=False, comment='cpu')
    disk = Column(VARCHAR(64), nullable=False, comment='disk')
    mem = Column(VARCHAR(512), comment='内存')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(String(20), comment='创建者')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class Mockapi(Base):
    __tablename__ = 'mockapi'
    __table_args__ = {'comment': 'mock接口表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    modelid = Column(BIGINT, nullable=False, comment='模块Id')
    modelname = Column(VARCHAR(64), comment='模块名')
    apiname = Column(VARCHAR(64), comment='接口')
    apiurl = Column(VARCHAR(200), comment='url')
    apitype = Column(VARCHAR(64), comment='接口类型')
    requesttype = Column(VARCHAR(20), comment='请求类型')
    timeout = Column(BIGINT, nullable=False, comment='超时')
    memo = Column(VARCHAR(64), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')


class Mockapirespone(Base):
    __tablename__ = 'mockapirespone'
    __table_args__ = {'comment': 'mock接口响应表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    apiid = Column(BIGINT, nullable=False, comment='接口Id')
    responecode = Column(VARCHAR(20), comment='接口')
    responecontent = Column(TEXT, comment='响应内容')
    status = Column(VARCHAR(20), comment='状态')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')


class Mockmodel(Base):
    __tablename__ = 'mockmodel'
    __table_args__ = {'comment': 'mock模块表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    modelcode = Column(VARCHAR(64), comment='模块编码')
    modelname = Column(VARCHAR(64), comment='模块名')
    memo = Column(VARCHAR(64), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')


class Performancereportfilelog(Base):
    __tablename__ = 'performancereportfilelog'
    __table_args__ = {'comment': '性能报告文件记录表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    execplanid = Column(BIGINT, nullable=False, comment='execplanid')
    batchid = Column(BIGINT, nullable=False, comment='batchid')
    caseid = Column(BIGINT, nullable=False, comment='caseid')
    slaverid = Column(BIGINT, nullable=False, comment='slaverid')
    filename = Column(VARCHAR(64), nullable=False, comment='文件名，planid+batchid+slaverid')
    status = Column(VARCHAR(20), nullable=False, comment='状态')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')


class Performancereportsource(Base):
    __tablename__ = 'performancereportsource'
    __table_args__ = {'comment': '性能报告路径表'}

    id = Column(BIGINT, primary_key=True, comment='环境Id')
    planid = Column(BIGINT, nullable=False, comment='执行计划Id')
    batchid = Column(BIGINT, nullable=False, comment='批次Id')
    batchname = Column(VARCHAR(64), nullable=False, comment='批次')
    slaverid = Column(BIGINT, nullable=False, comment='执行机Id')
    caseid = Column(BIGINT, nullable=False, comment='用例Id')
    testclass = Column(VARCHAR(64), nullable=False, comment='解析文件匹配sample')
    runtime = Column(Float(11, True), nullable=False, comment='运行时长')
    source = Column(VARCHAR(200), nullable=False, comment='解析文件目录')
    status = Column(VARCHAR(64), comment='待解析，已解析')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(64), comment='创建人')
    totalcasenums = Column(BIGINT, nullable=False, comment='用例数')
    totalcasepassnums = Column(BIGINT, nullable=False, comment='用例成功数')
    totalcasefailnums = Column(BIGINT, nullable=False, comment='用例失败数')


class Permission(Base):
    __tablename__ = 'permission'
    __table_args__ = {'comment': '权限表'}

    id = Column(BIGINT, primary_key=True, comment='权限Id')
    resource = Column(String(256), nullable=False, comment='权限对应的资源')
    code = Column(String(256), nullable=False, comment='权限的代码/通配符,对应代码中@hasAuthority(xx)')
    handle = Column(String(256), nullable=False, comment='对应的资源操作')

    roles = relationship('Role', secondary='role_permission')


class Planbantchexeclog(Base):
    __tablename__ = 'planbantchexeclog'
    __table_args__ = {'comment': '计划执行日志表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    batchid = Column(BIGINT, nullable=False, comment='批次Id')
    exec_time = Column(String(20), comment='执行时间')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    memo = Column(Text, comment='备注')


class ProcessTestcase(Base):
    __tablename__ = 'process_testcase'
    __table_args__ = {'comment': '流程用例表'}

    id = Column(BIGINT, primary_key=True, comment='主键Id')
    executeplanid = Column(BIGINT, nullable=False, comment='执行计划id')
    apiid = Column(BIGINT, nullable=False, comment='apiid')
    deployunitid = Column(BIGINT, nullable=False, comment='微服务id')
    deployunitname = Column(VARCHAR(64), nullable=False, comment='微服务')
    apiname = Column(VARCHAR(64), nullable=False, comment='API名')
    testcaseid = Column(BIGINT, nullable=False, comment='用例id')
    casename = Column(VARCHAR(64), nullable=False, comment='用例名')
    ordernum = Column(BIGINT, nullable=False, comment='顺序')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')


class Project(Base):
    __tablename__ = 'project'
    __table_args__ = {'comment': '项目迭代表'}

    id = Column(BIGINT, primary_key=True, comment='项目Id')
    projectname = Column(VARCHAR(64), comment='项目名')
    status = Column(VARCHAR(64), nullable=False, comment='项目状态')
    start_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='开始时间')
    end_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='结束时间')
    memo = Column(VARCHAR(128), nullable=False, comment='项目描述')
    creator = Column(VARCHAR(20), nullable=False, comment='创建人')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')


class Role(Base):
    __tablename__ = 'role'
    __table_args__ = {'comment': '角色表'}

    id = Column(BIGINT, primary_key=True, comment='角色Id')
    name = Column(String(64), unique=True, comment='角色名称')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='修改时间')


class Routeperformancereport(Base):
    __tablename__ = 'routeperformancereport'
    __table_args__ = {'comment': '性能结果路由表'}

    id = Column(BIGINT, primary_key=True, comment='路由Id')
    executeplanid = Column(BIGINT, comment='集合id')
    tablename = Column(VARCHAR(128), nullable=False, comment='表名')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')


class Scriptvariable(Base):
    __tablename__ = 'scriptvariables'
    __table_args__ = {'comment': '脚本变量表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    scriptvariablesname = Column(VARCHAR(64), comment='变量名')
    variablesdes = Column(VARCHAR(64), comment='变量描述')
    valuetype = Column(VARCHAR(64), comment='变量值类型')
    memo = Column(VARCHAR(200), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class Slaver(Base):
    __tablename__ = 'slaver'
    __table_args__ = {'comment': '服务器表'}

    id = Column(BIGINT, primary_key=True, comment='执行机Id')
    slavername = Column(VARCHAR(64), comment='执行机器名')
    ip = Column(VARCHAR(64), nullable=False, comment='ip')
    port = Column(VARCHAR(64), nullable=False, comment='端口')
    status = Column(VARCHAR(64), nullable=False, comment='状态，idle，running')
    stype = Column(VARCHAR(64), nullable=False, comment='执行机类型，功能机，性能机')
    memo = Column(VARCHAR(512), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    macaddress = Column(String(100), comment='mac地址')


class StaticsDeployunitandcase(Base):
    __tablename__ = 'statics_deployunitandcases'
    __table_args__ = {'comment': 'api微服务用例统计报告表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    deployunitid = Column(BIGINT, nullable=False, comment='执行计划id')
    deployunitname = Column(VARCHAR(64), comment='计划名')
    passrate = Column(Float(11, True), nullable=False, comment='成功率')
    totalcases = Column(BigInteger, nullable=False, comment='用例总数')
    totalpasscases = Column(BigInteger, nullable=False, comment='用例成功总数')
    totalfailcases = Column(BigInteger, nullable=False, comment='用例失败总数')
    runtime = Column(BigInteger, nullable=False, comment='运行时长')
    statics_date = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='统计日期')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class StaticsPlanandcase(Base):
    __tablename__ = 'statics_planandcases'
    __table_args__ = {'comment': 'api计划用例统计报告表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    testplanid = Column(BIGINT, nullable=False, comment='执行计划id')
    testplanname = Column(VARCHAR(64), comment='计划名')
    passrate = Column(Float(11, True), nullable=False, comment='成功率')
    totalcases = Column(BigInteger, nullable=False, comment='用例总数')
    totalpasscases = Column(BigInteger, nullable=False, comment='用例成功总数')
    totalfailcases = Column(BigInteger, nullable=False, comment='用例失败总数')
    runtime = Column(BigInteger, nullable=False, comment='运行时长')
    statics_date = Column(Date, nullable=False, comment='统计日期')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class Testcondition(Base):
    __tablename__ = 'testcondition'
    __table_args__ = {'comment': '条件表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    conditionname = Column(VARCHAR(64), comment='条件名')
    objectid = Column(BIGINT, comment='目标Id，计划，用例的id')
    objectname = Column(VARCHAR(64), comment='目标名')
    objecttype = Column(VARCHAR(64), comment='目标类型')
    conditiontype = Column(VARCHAR(64), comment='条件类型，前置，后置，其他')
    memo = Column(VARCHAR(200), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')
    deployunitname = Column(VARCHAR(64), comment='微服务名')
    apiname = Column(VARCHAR(64), comment='api名')
    apiid = Column(BIGINT, nullable=False, comment='apiid')
    deployunitid = Column(BIGINT, nullable=False, comment='deployunitid')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class TestconditionReport(Base):
    __tablename__ = 'testcondition_report'
    __table_args__ = {'comment': '条件报告表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    conditionid = Column(BigInteger, comment='条件id')
    conditiontype = Column(VARCHAR(64), comment='前置，后置')
    subconditionid = Column(BigInteger, comment='子条件id，接口，db，nosql条件id')
    conditionresult = Column(TEXT, comment='接口返回，数据库返回结果等等')
    conditionstatus = Column(VARCHAR(20), comment='条件完成状态，成功，失败')
    runtime = Column(BigInteger, nullable=False, comment='运行时长')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(VARCHAR(10), comment='创建者')
    batchname = Column(String(64), comment='批次')
    planname = Column(String(64), comment='计划名')
    testplanid = Column(BigInteger, comment='计划id')
    subconditiontype = Column(String(20), comment='子条件类型，接口，数据库，脚本其他')
    status = Column(String(64), comment='状态')
    subconditionname = Column(String(20), comment='子条件名')


class Tester(Base):
    __tablename__ = 'tester'
    __table_args__ = {'comment': '测试人员表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    testername = Column(VARCHAR(64), comment='测试人员姓名')
    testertitle = Column(VARCHAR(64), comment='测试人员职务')
    testerorg = Column(VARCHAR(64), comment='所属组织')
    testermemo = Column(VARCHAR(100), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')


class Testvariable(Base):
    __tablename__ = 'testvariables'
    __table_args__ = {'comment': '变量表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    testvariablesname = Column(VARCHAR(64), comment='变量名')
    testvariablestype = Column(VARCHAR(64), comment='变量类型，用例变量，全局变量')
    variablesexpress = Column(VARCHAR(210), comment='变量表达')
    memo = Column(VARCHAR(200), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    creator = Column(String(20), comment='创建者')
    variablesdes = Column(String(100), comment='变量描述')
    valuetype = Column(String(20), server_default=text("'String'"), comment='String，Number，Array,Bool,其他')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


class TestvariablesValue(Base):
    __tablename__ = 'testvariables_value'
    __table_args__ = {'comment': '变量值表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    planid = Column(BIGINT, nullable=False, comment='计划Id')
    planname = Column(VARCHAR(64), comment='计划名')
    caseid = Column(BIGINT, nullable=False, comment='用例Id')
    casename = Column(VARCHAR(64), comment='用例名')
    variablesid = Column(BIGINT, nullable=False, comment='变量Id')
    variablesname = Column(VARCHAR(64), comment='变量名')
    variablesvalue = Column(VARCHAR(2000), comment='变量值')
    memo = Column(VARCHAR(200), comment='备注')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    batchname = Column(String(64), comment='批次')
    variablestype = Column(VARCHAR(64), comment='变量类型')


class Variable(Base):
    __tablename__ = 'variables'
    __table_args__ = {'comment': '变量表'}

    id = Column(BIGINT, primary_key=True, comment='Id')
    variablesname = Column(VARCHAR(64), comment='变量名')
    variablestype = Column(VARCHAR(64), comment='变量类型')
    memo = Column(VARCHAR(200), nullable=False, comment='变量描述')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    lastmodify_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='上一次修改时间')
    variablecondition = Column(String(64), comment='变量条件')
    projectid = Column(BIGINT, server_default=text("'1'"), comment='项目id')


t_account_role = Table(
    'account_role', metadata,
    Column('account_id', ForeignKey('account.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
           nullable=False, comment='用户Id'),
    Column('role_id', ForeignKey('role.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, nullable=False,
           index=True, comment='角色Id'),
    comment='用户角色表'
)

t_role_permission = Table(
    'role_permission', metadata,
    Column('role_id', ForeignKey('role.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, nullable=False,
           comment='角色Id'),
    Column('permission_id', ForeignKey('permission.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
           nullable=False, index=True, comment='权限Id'),
    comment='角色权限表'
)

if __name__ == '__main__':
    Base.metadata.create_all(bind=engine)
